SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO




CREATE PROCEDURE [dbo].[usp_SearchTeacher]
    (
      @fdTeacLoginID VARCHAR(50) ,
      @fdTeacName VARCHAR(50) ,
      @fdTeacLevel INT
      
    )
AS 
    SELECT  a.fdTeacLoginID ,
            a.fdTeacName ,
            b.fdCollName ,
            CASE a.fdTeacLevel
              WHEN 0 THEN '全部'
              WHEN 1 THEN '本科'
              WHEN 2 THEN '研究生'
            END
    FROM    dbo.FS_Teacher AS a
            INNER JOIN dbo.FS_College AS b ON a.fdTeacCollID = b.fdCollID
    WHERE   ( a.fdTeacName LIKE '%' + @fdTeacName + '%' )
            AND ( a.fdTeacLoginID LIKE '%' + @fdTeacLoginID + '%' )
            AND a.fdTeacLevel = @fdTeacLevel
    --IF @fdTeacLoginID = ''
    --    AND (
    --          NOT ( @fdTeacName = '' )
    --        ) 
    --    SELECT  fdTeacCollID,
    --            fdTeacLoginID,
    --            fdTeacName
    --    FROM    dbo.FS_Teacher
    --    WHERE   ( fdTeacName LIKE '%' + @fdTeacName + '%' )
    --            AND fdTeacLevel = @fdTeacLevel
    --ELSE 
    --    BEGIN
    --        IF @fdTeacName = ''
    --            AND (
    --                  NOT ( @fdTeacLoginID = '' )
    --                ) 
    --            SELECT  fdTeacCollID,
    --                    fdTeacLoginID,
    --                    fdTeacName
    --            FROM    dbo.FS_Teacher
    --            WHERE   ( fdTeacLoginID LIKE '%' + @fdTeacLoginID + '%' )
    --                    AND fdTeacLevel = @fdTeacLevel
    --        ELSE 
    --            IF @fdTeacLoginID = ''
    --                AND @fdTeacName = '' 
    --                SELECT  fdTeacCollID,
    --                        fdTeacLoginID,
    --                        fdTeacName
    --                FROM    dbo.FS_Teacher
    --                WHERE   fdTeacLevel = @fdTeacLevel
    --    END







GO
